@CLASS
appModuleBase

@USE
pf/web/pfSiteModule.p

@BASE
pfSiteModule

#----- Constructor -----

@create[aOptions]
  ^cleanMethodArgument[]
  ^BASE:create[$aOptions]

  $_core[$aOptions.core]
  $_formater[$aOptions.formater]
  $_antiFlood[$aOptions.antiFlood]

  $_isDebug($aOptions.isDebug)

  $_title[]
  $_now[^date::now[]]

  ^assignVar[now;^date::now[]]
  ^assignVar[antiFlood;$antiFlood]
  ^assignVar[linkTo;$linkTo]

@GET_core[]
  $result[$_core]

@GET_isDebug[]
  $result($_isDebug)

@GET_formater[]
  $result[$_formater]

@GET_title[]
  $result[$_title]

@GET_antiFlood[]
  ^if(!def $_antiFlood){
    ^use[pf/web/helpers/pfAntiFlood.p]
    $_antiFlood[^pfAntiFlood::create[$.path[/../data/antiflood] $.expires(120*60)]]
  }
  $result[$_antiFlood]

@SET_title[aValue]
  $_title[$aValue]
  ^assignVar[title;$_title]

@onNOTFOUND[aRequest]
  $result[^pfHTTPResponseNotFound::create[]]

@assignModule[aModuleName;aOptions]
  ^cleanMethodArgument[]
  $result[]
  $lArgs[
    $.core[$core]
    $.formater[$_formater]
    $.isDebug($_isDebug)
  ]

  ^if(!def $aOptions.args){
    ^aOptions.add[$.args[$lArgs]]
  }{
     $aOptions.args[^aOptions.args.union[$lArgs]]
   }
  ^BASE:assignModule[$aModuleName;$aOptions]

@onINDEX[aRequest] 
  Module!

@postHTML[aResponse]
  ^if(!def $aResponse.title){
    $aResponse.title[$title]
  }
  $result[$aResponse]
